package com.jumi.microservice.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jm.member.common.core.web.page.TableDataInfo;
import com.jumi.microservice.enums.CommonEnum;
import com.jumi.microservice.service.IJmUserLevelChangeLogService;
import com.jumi.microservice.service.IJmUserService;
import com.jumi.microservice.service.PageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 等级变更表 前端控制器
 * </p>
 *
 * @author 要挑客户管理团队
 * @since 2020-07-14
 */
@RestController
@RequestMapping("/jm-user-level-change-log")
@Api(value = "用户等级更改日志", tags = {"用户等级更改日志"})
public class JmUserLevelChangeLogController {

    @Autowired
    IJmUserService userService;

    @Autowired
    IJmUserLevelChangeLogService userLevelChangeLogService;

    @PostMapping("/getPage")
    @ApiOperation("查询会员等级更改日志")
    public TableDataInfo getPage(Integer uid, Integer current, Integer size) {
        userService.checkUserExist(uid);
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("uid", uid);
        wrapper.eq("is_del", CommonEnum.否);
        wrapper.orderByDesc("id");
        Page page = userLevelChangeLogService.getPage(new Page(current, size), wrapper);
        TableDataInfo dataTableInfo = PageService.getDataTableInfo(page);
        return dataTableInfo;
    }
}
